package com.kefu.chat.service;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.chat.mapper.ChatChannelMapper;
import com.kefu.chat.mapper.ChatPosterMapper;
import com.kefu.chat.model.ChatChannel;
import com.kefu.chat.model.ChatPoster;
import com.kefu.chat.vo.ChatPosterChannelVo;
import com.kefu.common.service.AbstractKefuService;
import com.kefu.common.util.Assert;
import com.kefu.common.util.JacksonUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

@Service
public class ChatPosterService extends AbstractKefuService<ChatPoster> {
    @Resource
    private ChatPosterMapper chatPosterMapper;
    @Resource
    private ChatChannelMapper chatChannelMapper;

    @Override
    public void deleteById(String id) {
        Long count = chatChannelMapper.selectCount(Wrappers.lambdaQuery(ChatChannel.class)
                .like(ChatChannel::getPosterIds, id));
        Assert.isTrue(count>0,  "广告已经被绑定，不能删除!");
        super.deleteById(id);
    }
}
